import BigNumber from "bignumber.js";

export const formatAmount = (str, nb = 2) => {
 const BN = BigNumber.clone();
 BN.config({
  FORMAT: {
   prefix: '',
   decimalSeparator: '.',
   groupSeparator: ',',
   groupSize: 3,
   secondaryGroupSize: 0,
   fractionGroupSeparator: ' ',
   fractionGroupSize: 0,
   suffix: '',
  },
 });

 const n = new BN(str);
 return n.isNaN() ? '--' : n.toFormat(nb);
};